package com.edushare.common.util;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;

import com.edushare.common.constants.ApplicationConstants;

public class DateTimeUtil{
	
	public static final ArrayList<String> monthList = new ArrayList<String>();
	static{
		monthList.add("January");
		monthList.add("February");
		monthList.add("March");
		monthList.add("April");
		monthList.add("May");
		monthList.add("June");
		monthList.add("July");
		monthList.add("August");
		monthList.add("September");
		monthList.add("October");
		monthList.add("November");
		monthList.add("December");
	}

	public static String getYear(Date date) {
		if(date!=null)
			return new SimpleDateFormat("yyyy").format(date);
		return null;
	}

	public static String getMonth(Date date) {
		if(date!=null)
			return new SimpleDateFormat("MMMM").format(date);
		return null;
	}
	
	/** Returns EOTD for a given date. EOTD == 23:59:00 HOUR */
	public static Date getEOTD(Date date){
		GregorianCalendar gc = new GregorianCalendar();
		gc.setTime(date);
		gc.set(GregorianCalendar.HOUR_OF_DAY, 23);
		gc.set(GregorianCalendar.MINUTE, 59);
		return gc.getTime();
	}

	public static String formatDate(Date date) {
		return new SimpleDateFormat(ApplicationConstants.DATE_FORMAT).format(date);
	}

	public static String formatTimestamp(Date date) {
		return new SimpleDateFormat(ApplicationConstants.TIMESTAMP_FORMAT).format(date);
	}
}
